import axios from 'axios';
import { baseURL } from '../utils/http.js'; // 引入基础URL
import { createHydrationRenderer } from 'vue';

export const getOrderByUserid = (userid) => {
    console.log(`获取用户订单地址${baseURL}/order/getOrderByUserid?userid=${userid}`); // 更新为正确的URL
    return axios.get(`${baseURL}/order/getOrderByUserid?userid=${userid}`);
};



export const getOrderProductByOrderid = (orderid) => {
    console.log(`获取订单商品地址${baseURL}/order/getOrderProductByOrderid?orderid=${orderid}`); // 更新为正确的URL
    return axios.get(`${baseURL}/order/getOrderProductByOrderid?orderid=${orderid}`);
};
// 创建订单
// 参数：一个json对象（包含order对象和orderproduct对象数组）取名为创建订单对象 createorderjson

export const createOrder = (orderData) => {
    console.log(`创建订单地址${baseURL}/order/createOrder`); // 更新为正确的URL
    return axios.post(`${baseURL}/order/createOrder`, orderData);
}; 


export const cancelOrder = (orderid) => {
    console.log(`删除订单地址${baseURL}/order/cancelOrder?orderid=${orderid}`); // 更新为正确的URL
    return axios.delete(`${baseURL}/order/cancelOrder?orderid=${orderid}`);
};

